$('.type.right.fontLeft.point').click(function(){
	if( $('.type.right.fontLeft.point .dropDown').css('display') == 'none' ){
		$('.type.right.fontLeft.point .dropDown').css({'display':'block'});
	}else{
		$('.type.right.fontLeft.point .dropDown').css({'display':'none'});
	}
})
$('.need.marright.left.fontLeft.point').click(function(){
	if( $('.need.marright.left.fontLeft.point .dropDown').css('display') == 'none' ){
		$('.need.marright.left.fontLeft.point .dropDown').css({'display':'block'});
	}else{
		$('.need.marright.left.fontLeft.point .dropDown').css({'display':'none'});
	}
})
$('.need.marright.left.fontLeft.point .dropDown li').click(function(e){
	e.stopPropagation();
	$('.need.marright.left.fontLeft.point .input .innerHtml').html(e.target.innerHTML);
	$('.need.marright.left.fontLeft.point .input .innerHtml').attr('name',$(e.target).attr("name"))
	$('.need.marright.left.fontLeft.point .input .innerHtml').css({'color':'#333'});
	$('.need.marright.left.fontLeft.point .dropDown').css({'display':'none'});
})
$('.type.right.fontLeft.point .dropDown li').click(function(e){
	e.stopPropagation();
	$('.type.right.fontLeft.point .input .innerHtml').html(e.target.innerHTML);
	$('.type.right.fontLeft.point .input .innerHtml').attr('name',$(e.target).attr("name"));
	$('.type.right.fontLeft.point .input .innerHtml').css({'color':'#333'});
	$('.type.right.fontLeft.point .dropDown').css({'display':'none'});
});
var onoff = false;
$('#submit').click(function(){
	if(onoff){return false;}
	onoff=true;
	var names = $('.phonename').val();
	var email = $('.email').val();
	var innerHtml = $('.inner').html();
	var inner = $('.inners').html();
	var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
	var medi = $('.inner').attr('name');
	var medis = $('.inners').attr('name');
	if(names == ''){
		$('#bottom_tip').html('请填写姓名');
		Tipanimate()
	}else if(innerHtml == '需求 / 所属行业'){
		$('#bottom_tip').html('请选择所属行业');
		Tipanimate()
	}else if(inner == '账号类型'){
		$('#bottom_tip').html('请选择账号类型');
		Tipanimate();
	}else if(email==''){
		$('#bottom_tip').html('请填写邮箱账号');
		Tipanimate();
	}else if(!reg.test(email)){
		$('#bottom_tip').html('请填写正确邮箱');
		Tipanimate();
	}else{
		var wid = localStorage.getItem('wid');
		$.ajax({
			type:"POST",
			url: apiCollect.apiRegisterObject,
			data:{
				registered: 1,
				media_name:names,
				media_demand:medi,
				media_type:medis,
				email:email,
				wid:wid,
			},
			success:function(data){
				if(data.code==000000){
					localStorage.setItem('token',data.data.token_key);
					localStorage.setItem('wid', data.data.wid);
					window.location.href='../index.html';
				}else{
					$('#bottom_tip').html(data.message);
					Tipanimate();
				}
			}
		});
	}
});
//公共函数
function Tipanimate(){
	$('#bottom_tip').animate({'height':'40px'},200);
	$('#bottom_tip').delay(1000).animate({'height':'0px'},200,function(){$('#bottom_tip').html('');onoff=false;});
}
function getQuery(name){
	var url = location.search;
	var reg = new Object();
	if(url.indexOf('?')!=-1){
		var str = url.substr(1);
		var strs = str.split('&');
		for(var i=0;i<strs.length;i++){
			reg[strs[i].split('=')[0]]=unescape(strs[i].split('=')[1]);
		}
	}
	return reg;
}

$(document).on('keydown', function (ev) {
	if (ev.keyCode == 13) {
		$('#submit').trigger('click');
	}
})

// $('#logo_info').click(function () {
// 	window.location.href = '/';
// })